package com.mybatis.generator;

import com.mybatis.generator.codegen.CodeGenerator;
import com.mybatis.generator.config.CodeGeneratorConfig;

public class GeneratorMain {

    private static CodeGeneratorConfig config = new CodeGeneratorConfig();

    static {
        config.setDbDriverClassName("com.mysql.jdbc.Driver");
        config.setDbName("zhengtoon_form");
        config.setDbUrl("jdbc:mysql://172.28.5.92:3306/zhengtoon_form?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8");
        config.setDbUserName("syswin");
        config.setDbUserPassword("syswin");

        config.setCodeCommentsAuthor("bitianwei@syswin.com");
        // 代码生成路径
        config.setCodeGeneratorPath("F:\\code\\mysql_template\\");
        // 模板存放路径
        String absolutePath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
        String path = absolutePath + "/templates/generalTemplates";
        config.setTemplatePath(path);
        // 基础包名
        config.setClassBasePackage("com.zhengtoon.form");

        config.setClassPackageDaoImpl("persistence.mapper");
        config.setClassPackageDao("persistence.mapper");
        config.setClassPackageEntity("bean");

        config.setClassPackageController("web.controller");
        config.setClassNameControllerSuffix("Controller");

        config.setTableNameReplaceChar("t_");

    }

    public static void main(String[] args) throws Exception {
        CodeGenerator hf = new CodeGenerator(config);
        hf.genAllTable();
    }
}
